package vn.appsmobi.ui;
import vn.appsmobi.R;
import vn.appsmobi.model.AppCommentInfo;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.RatingBar;
import android.widget.TextView;

public class AppCommentsItem extends LinearLayout
{
  private ExpandableTextView mContent;
  private String mCurrentVersion = "";
  private TextView mDate;
  private RatingBar mRatingBar;
  private TextView mUserName;
  private TextView mVersion;
  private Context _context;

  public AppCommentsItem(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    _context = paramContext;
  }

  public void bind(AppCommentInfo paramAppCommentInfo)
  {
    initResource();
  }

  public ExpandableTextView getCommentContentView()
  {
    return this.mContent;
  }

  public void initResource()
  {
    this.mContent = ((ExpandableTextView)findViewById(R.id.content));
    this.mContent.setEllipsize(TextUtils.TruncateAt.END);
    this.mContent.setMaxLines(4);
    this.mRatingBar = ((RatingBar)findViewById(R.id.ratingbar));
   
    this.mDate = ((TextView)findViewById(R.id.description));
    this.mVersion = ((TextView)findViewById(R.id.version));
  }

  public void rebind(AppCommentInfo commentinfo)
  {
    this.mContent.setText(commentinfo.mContent);
    this.mRatingBar.setRating((float)commentinfo.mRating);
    this.mVersion.setText(commentinfo.mVersion);    
    this.mDate.setText(_context.getString(R.string.app_comments_description,commentinfo.mUserName,commentinfo.mTime) );
    
  }

  public void setCurrentVersion(String version)
  {
    this.mCurrentVersion = version;
  }
}
